package com.an.jackjson;

import java.io.IOException;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.an.json.UserData;
import com.fasterxml.jackson.databind.ObjectMapper;

public class JackTest {

	public static void main(String[] args) throws IOException {
		ObjectMapper mapper = new ObjectMapper();

		UserData userData = new UserData();
		userData.setAreaCode("123");
		List<String> list = new ArrayList<String>();
		list.add("活着");
		list.add("许三观卖血记");
		list.add("许三观卖血记");
		list.add("许三观卖血记");

		userData.setBlackList(list);

		System.out.println("JSON:" + mapper.writeValueAsString(userData));

		System.out.println("JSON2OBJ:" + mapper.readValue(mapper.writeValueAsString(userData), UserData.class));

		Map<String, String> map = new HashMap<String, String>();
//		map.put("name", "12");
		A a2= new A();
		a2.setName("asasa");
		System.out.println("a2:" + mapper.writeValueAsString(a2));
		System.out.println(mapper.writeValueAsString(map));
		A a = mapper.readValue(mapper.writeValueAsString(map), A.class);
		System.out.println("map.size():" + map.size() + "a:" + a.getName());

	}

	
}
class A implements Serializable{
	
	private String name;

	public String getName() {
		return name;
	}

	public A() {
	}

	public void setName(String name) {
		this.name = name;
	}

}
